# -*- coding: utf-8 -*-
"""
Created on  2020
@author: qq626439197
"""
# In[156]:
import warnings
warnings.filterwarnings("ignore")
from keras.layers.recurrent import LSTM
from keras.layers import Dense, Activation ,Dropout , Flatten , Conv1D ,MaxPooling1D,Bidirectional,RNN,GRU
from sklearn.svm import SVR
from keras.models import *
from keras import losses
# In[156]:
def SVR_model(x_train,y_train):
    
    model = SVR(kernel='rbf', C=50, gamma=0.06)
    model.fit(x_train,y_train)
    
    return model
# In[156]:
def BPNN_model(x_train,y_train,sequence_length,n_multi,epochs,verbose):
    
    model = Sequential()
    model.add(Dense(64))
    model.add(Dense(12)) 
    model.add(Flatten())
    model.add(Dense(1))  
    model.compile(loss='mean_squared_error', optimizer='adam') 
    model.fit(x_train,y_train,epochs=epochs,verbose=verbose)
    
    return model
# In[158]:
def alo_LSTM_model(x_train,y_train,sequence_length,alo,epochs,verbose):
    model = Sequential()
    #LSTM
    model.add(LSTM(int(alo[0]),input_shape=(x_train.shape[1],1),return_sequences=True))
    #model.add(Dropout(0.5))
    # model.add(LSTM(int(alo[0])))
    model.add(LSTM(int(alo[1])))
    #model.add(Dropout(0.5))
    model.add(Dense(1))
    model.compile(loss='mean_squared_error',optimizer='adam')
    model.fit(x_train,y_train,epochs=epochs,validation_split=0,verbose=verbose)
    
    return model
# In[158]:
def LSTM_model(x_train,y_train,sequence_length,n_multi,epochs,verbose):
    model = Sequential()
    #LSTM
    #model.add(Conv1D(128,kernel_size=4,input_shape=(input[1],input[2]),padding='valid'))
    model.add(LSTM(24,input_shape=(x_train.shape[1],1),return_sequences=True))
    # model.add(Dropout(0.5))
    model.add(LSTM(8))
    # model.add(LSTM(16))
    #model.add(Dropout(0.5))
    model.add(Dense(1))
    model.compile(loss='mae',optimizer='adam')
    model.fit(x_train,y_train,epochs=epochs,verbose=verbose)
    
    return model